<?php
namespace app\admin\model;
use app\common\BaseModel;
use app\admin\model\CateGory;
class Good extends BaseModel{

	public function add(){
		$this->save((input()));
         return  self::$validate->getError();
	}
	public function getCategoryIdAttr($value)
    {
        return CateGory::getCategoryName($value);
    }
	public function Aselect($page,$limit){

		$good = $this->limit(($page-1)*$limit,$limit)->select();
		$total = $this->count();
		return ['code'=>0,'good'=>$good,'total'=>$total,'paginate'=>$this->paginate];
	}	
	public function updateGood(){

		$this->save(input(),['id'=>input('id')]);
         return  self::$validate->getError();
	}
}